﻿using System;
using System.Collections.Generic;
using System.Net;
using System.Text;

namespace UtilZ.Dotnet.Ex.Communication.Net.BMQ
{
    /// <summary>
    /// BMQ订阅信息
    /// </summary>
    public class BMQSubscribeInfo
    {
        /// <summary>
        /// 主题
        /// </summary>
        public short Topic { get; private set; }

        /// <summary>
        /// 消息输出回调
        /// </summary>
        private readonly Action<BMQSubscribeInfo, IBMQDataMessage> _messageOutputCallbacck;


        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="topic">主题</param>
        /// <param name="messageOutputCallbacck">消息输出回调</param>
        public BMQSubscribeInfo(short topic, Action<BMQSubscribeInfo, IBMQDataMessage> messageOutputCallbacck)
        {

            if (messageOutputCallbacck == null)
            {
                throw new ArgumentNullException(nameof(messageOutputCallbacck));
            }


            this.Topic = topic;
            this._messageOutputCallbacck = messageOutputCallbacck;
        }


        /// <summary>
        /// 输出消息
        /// </summary>
        /// <param name="message">消息</param>
        internal void OnRaiseMessageOutput(IBMQDataMessage message)
        {
            this._messageOutputCallbacck(this, message);
        }

    }
}
